package com.net.xpay.common.manager.impl;

import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.net.common.dao.BasicMapper;
import com.net.xpay.common.dao.FlexibleStaffAuthenticationMapper;
import com.net.xpay.common.domain.FlexibleStaffAuthentication;
import com.net.xpay.common.manager.FlexibleStaffAuthenticationManager;
import com.net.common.manager.AbstractManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;


@Component
public class FlexibleStaffAuthenticationManagerImpl extends AbstractManager<FlexibleStaffAuthentication> implements FlexibleStaffAuthenticationManager{

    @Autowired
    private FlexibleStaffAuthenticationMapper mapper;


    @Override
    protected BasicMapper<Long, FlexibleStaffAuthentication> getMapper() {
        return mapper;
    }

    @Override
    public FlexibleStaffAuthentication findByImportBizNo(Long userId, String importBizNo) {
        Preconditions.checkArgument(userId != null && !Strings.isNullOrEmpty(importBizNo));
        FlexibleStaffAuthentication condition = new FlexibleStaffAuthentication();
        condition.setUserId(userId);
        condition.setImportBizNo(importBizNo);
        return getByCondition(condition);
    }

    @Override
    public FlexibleStaffAuthentication getByOutBizNo(String outBizNo) {
        Preconditions.checkArgument(!Strings.isNullOrEmpty(outBizNo));
        FlexibleStaffAuthentication condition = new FlexibleStaffAuthentication();
        condition.setOutBizNo(outBizNo);
        return getByCondition(condition);
    }

    @Override
    public List<Long> listInitIds() {
        List<Long> ids = mapper.listInitIds();
        return ids == null ? new ArrayList<>() : ids;
    }
}
